/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Table;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Id;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;


import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author julianDavidPG
 */
@Entity
@Table(name = "PERSON")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Person.findAll", query = "SELECT p FROM Person p"),
    @NamedQuery(name = "Person.findById", query = "SELECT p FROM Person p WHERE p.id = :id"),
    @NamedQuery(name = "Person.findByDocument", query = "SELECT p FROM Person p WHERE p.document = :document"),
    @NamedQuery(name = "Person.findByName", query = "SELECT p FROM Person p WHERE p.name = :name"),
    @NamedQuery(name = "Person.findByLastName", query = "SELECT p FROM Person p WHERE p.lastName = :lastName"),
    @NamedQuery(name = "Person.findByPassword", query = "SELECT p FROM Person p WHERE p.password = :password"),
    @NamedQuery(name = "Person.findByUserName", query = "SELECT p FROM Person p WHERE p.userName = :userName"),
    @NamedQuery(name = "Person.findByBalance", query = "SELECT p FROM Person p WHERE p.balance = :balance") })
public class Person implements Serializable {
    /**Identification for Serialization.
     */
    private static final long serialVersionUID = 1L;
    /**Anotation to identify and map the Id attribute.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID")
    private Long id;
    /**Anotation to identify and map the document attribute.
     */
    @Column(name = "DOCUMENT")
    private String document;
    /**Anotation to indicate the attribute like Optional.
     */
    @Basic(optional = false)
    @Column(name = "NAME")
    private String name;
    /**Anotation to indicate the attribute like Optional.
     */
    @Basic(optional = false)
    @Column(name = "LAST_NAME")
    private String lastName;
    /**Anotation to indicate the attribute like Optional.
     */
    @Basic(optional = false)
    @Column(name = "PASSWORD")
    private String password;
    /**Anotation to indicate the attribute like Optional.
     */
    @Basic(optional = false)
    @Column(name = "USER_NAME")
    private String userName;
    /**Anotation to indicate the attribute like Optional.
     */
    @Basic(optional = false)
    @Column(name = "BALANCE")
    private double balance;

    /**Default Constructor.
     */
    public Person() {
    }

    /**Constructor using Id for the person.
     * @param givenId The Id given for the creation of the object
     */
    public Person(final Long givenId) {
        this.id = givenId;
    }

    /**Constructor using all of the attributes for the person.
     * @param givenId The attribute value
     * @param givenName The attribute value
     * @param givenLastName The attribute value
     * @param givenPassword The attribute value
     * @param givenUserName The attribute value
     * @param givenBalance The attribute value
     */
    public Person(final Long givenId, final String givenName, final String givenLastName, 
            final String givenPassword, final String givenUserName, final double givenBalance) {
        this.id = givenId;
        this.name = givenName;
        this.lastName = givenLastName;
        this.password = givenPassword;
        this.userName = givenUserName;
        this.balance = givenBalance;
    }

    /**Getter for Id attribute.
     * @return The id's attribute value
     */
    public Long getId() {
        return id;
    }

    /**Setter for Id attribute.
     * @param givenId The new Id value
     */
    public void setId(final Long givenId) {
        this.id = givenId;
    }

    /**Getter for Document attribute.
     * @return The document's attribute value
     */
    public String getDocument() {
        return document;
    }

    /**Setter for Document attribute.
     * @param givenDocument The new Document value
     */
    public void setDocument(final String givenDocument) {
        this.document = givenDocument;
    }

    /**Getter for Name attribute.
     * @return The name's attribute value
     */
    public String getName() {
        return name;
    }

    /**Setter for Name attribute.
     * @param givenName The new Name value
     */
    public void setName(final String givenName) {
        this.name = givenName;
    }

    /**Getter for Last Name attribute.
     * @return The Last Name's attribute value
     */
    public String getLastName() {
        return lastName;
    }

    /**Setter for Last Name attribute.
     * @param givenLastName The new Last Name value
     */
    public void setLastName(final String givenLastName) {
        this.lastName = givenLastName;
    }

    /**Getter for Password attribute.
     * @return The password's attribute value
     */
    public String getPassword() {
        return password;
    }

    /**Setter for Password attribute.
     * @param givenPassword The new Password value
     */
    public void setPassword(final String givenPassword) {
        this.password = givenPassword;
    }

    /**Getter for Username attribute.
     * @return The username's attribute value
     */
    public String getUserName() {
        return userName;
    }

    /**Setter for Username attribute.
     * @param givenUserName The new Username value
     */
    public void setUserName(final String givenUserName) {
        this.userName = givenUserName;
    }

    /**Getter for Balance attribute.
     * @return The balance's attribute value
     */
    public double getBalance() {
        return balance;
    }

    /**Setter for Balance attribute.
     * @param givenBalance The new Balance value
     */
    public void setBalance(final double givenBalance) {
        this.balance = givenBalance;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {        
        if (!(object instanceof Person)) {
            return false;
        }
        Person other = (Person) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Person[ id=" + id + " ]";
    }
    
}
